﻿@model P2PWeb.Models.Account
@{
    ViewBag.Title = "AccountUploadify";
}




<link href="@Url.Content("~/Content/borrow.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/uploadify.css")" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="@Url.Content("~/Scripts/app/UploadFile.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/app/Accountuploadify.js")"></script>


<div class="main ">
    <div class="main_top"><span class="main_top_right"></span></div>
    <div class="ouheeMain_box">
        <div class="loan_box">
            <h2 class="content_title ml_neg_75 png">上传个人信息</h2>
        </div>
        @using (Html.BeginForm("SubmitUploadify", "Account"))
        {
            @Html.AntiForgeryToken()
            @Html.Hidden("ID", Model.AccountAuthentication.ID)

            <div class="imhint">
                个人信息证明的照片的文件格式必须为jpg,png,bmp其中之一，并且文件大小必须在2M以内
            </div>
            <table>
                <tr>
                    <td>姓名 
                        <input type="text" name="RealName" value="@Model.AccountAuthentication.RealName" />
                    </td>
                    <td>身份证 
                        <input type="text" name="IDCard" value="@Model.AccountAuthentication.IDCard" />
                    </td>
                </tr>
            </table>
           
            <table class="attachmentsList">
            </table>
            <script>
                function deletingRow(deleteRow, rowConfig) {
                    deleteRow.before(CreateUploadRow(function (row, data) {
                        updatedRowSurcess(row, data, rowConfig);
                    }, null, function (cancelRow) {
                        deletingRow(cancelRow, rowConfig);
                    }));
                    deleteRow.remove();
                }

                function updatedRowSurcess(row, data, rowConfig) {
                    row.before(CreateUploadedRow(data.FileName, rowConfig.name, function (deleteRow) {
                        deletingRow(deleteRow, rowConfig);
                    }));
                    row.remove();
                }

                function createRow(rowConfig, table) {
                    var header = $('<tr><th class="left_td" colspan="2"></th></tr>');
                    header.find('th').html(rowConfig.category + "<span style='color:red;'></span>");
                    if (rowConfig.name == "JobUrl") {
                        header.find('th').html(rowConfig.category);
                    }
                    var content = null;
                    if (rowConfig.fileName) {
                        content = CreateUploadedRow(rowConfig.fileName, rowConfig.info, rowConfig.name, function (deleteRow) {
                            deletingRow(deleteRow, rowConfig);
                        });
                    }
                    else {
                        content = CreateUploadRow(function (row, data) {
                            updatedRowSurcess(row, data, rowConfig);
                        });
                    }
                    header.appendTo(table);
                    content.appendTo(table);
                }

                $(document).ready(function () {
                    var table = $('.attachmentsList');
                    var rowList = [];
                    @{
            string fileName = string.IsNullOrWhiteSpace(Model.AccountAuthentication.IDCard) ? "null" : "\"" + Model.AccountAuthentication.IDCardUrl + "\"";
            string jsonString = string.Format("category: \"身份证照片正面\", name: \"IDCardUrl\", fileName:{0} ", fileName);
                        @Html.Raw("rowList.push({ " + jsonString + " });");
                                                                          string fileName1 = string.IsNullOrWhiteSpace(Model.AccountAuthentication.IDCard) ? "null" : "\"" + Model.AccountAuthentication.IDCardUrlNegative + "\"";
                                                                          string jsonString1 = string.Format("category: \"身份证照片反面\" , name: \"IDCardUrlNegative\", fileName:{0} ", fileName1);
                        @Html.Raw("rowList.push({ " + jsonString1 + " });");
                                                                           fileName = Model.AccountAuthentication.JobUrl == null ? "null" : "\"" + Model.AccountAuthentication.JobUrl + "\"";
                                                                           jsonString = string.Format("category: \"最近连续6个月工资卡存折/银行流水(需携带身份证、工资卡/存折去发放工资银行打印并盖章 或 工资卡网银截图)\" , name: \"JobUrl\", fileName:{0} ", fileName);
                        @Html.Raw("rowList.push({ " + jsonString + " });");

                                                                          fileName = Model.AccountAuthentication.CreditReportUrl == null ? "null" : "\"" + Model.AccountAuthentication.CreditReportUrl + "\"";
                                                                          jsonString = string.Format("category: \"个人信用报告(需带身份证和复印件去当地人民银行分行打印，2周内开具有效)\",name: \"CreditReportUrl\", fileName:{0} ", fileName);
                        @Html.Raw("rowList.push({ " + jsonString + " });");

                                                                          fileName = Model.AccountAuthentication.HomeUrl == null ? "null" : "\"" + Model.AccountAuthentication.HomeUrl + "\"";
                                                                          jsonString = string.Format("category: \"住址证明(房产登记证或房产使用权证明 或 有中介机构盖章证实的租房合同 或 近一个月的水、电、煤、有线电视或固定电话账单)\" , name: \"HomeUrl\", fileName:{0} ", fileName);
                        @Html.Raw("rowList.push({ " + jsonString + " });");

                                                                          fileName = Model.AccountAuthentication.WorkUrl == null ? "null" : "\"" + Model.AccountAuthentication.WorkUrl + "\"";
                                                                          jsonString = string.Format("category: \"工作证明(工作证、劳动合同、社保公积金、单位工牌 或 加盖单位公章的在职证明（两周内）均可)\" , name: \"WorkUrl\", fileName:{0} ", fileName);
                        @Html.Raw("rowList.push({ " + jsonString + " });");
                                                                          fileName = Model.AccountAuthentication.HeadUrl == null ? "null" : "\"" + Model.AccountAuthentication.HeadUrl + "\"";
                                                                          jsonString = string.Format("category: \"个人头像(1.正面、免冠、清晰本人照片；2.图片尺寸：800X600（最低）)\" , name: \"HeadUrl\", fileName:{0} ", fileName);
                        @Html.Raw("rowList.push({ " + jsonString + " });");
                        
                    }
                    for (rowIndex in rowList) {
                        var rowConfig = rowList[rowIndex];
                        createRow(rowConfig, table);
                    }
                });

            </script>
            <div class="obtn02">
                <span id="uploading" class="onext">确认提交</span>
            </div>
        }

    </div>
    <div class="main_bottom"><span class="main_bottom_right"></span></div>
</div>


